<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui">

<h:head>
	<title>Creazione gift list</title>
</h:head>
<h:body>
	<h:form>

		<p:outputPanel id="addToGF"
			rendered="#{giftlistBean.renderAddingSection}">

			<h6>You are about to add the following product to a gift list</h6>
			<h:outputText rendered="#{giftlistBean.addedProd == 1}"
				value="#{giftlistBean.p.id} - #{giftlistBean.p.dataInizio} - #{giftlistBean.p.dataFine} - #{giftlistBean.p.descrizione}" />

			<h:outputText rendered="#{giftlistBean.addedProd == 2}"
				value="#{giftlistBean.pb.id} - #{giftlistBean.pb.dataInizio} - #{giftlistBean.pb.dataFine} " />


			<h6>Select a gift list for adding</h6>

			<h:panelGrid id="displayGfs" columns="2" cellpadding="5"
				rendered="#{giftlistBean.renderAddingSection}">

				<p:dataTable var="glDTO" value="#{giftlistBean.glsDTO}"
					paginator="true" rows="10" rowKey="#{glDTO.id}">

					<p:column headerText="id">
						<h:outputText value="#{glDTO.id}" />
					</p:column>

					<p:column headerText="name">
						<h:outputText value="#{glDTO.name}" />
					</p:column>

					<p:column style="width:4%">
						<p:commandButton id="selectButton" icon="ui-icon-plus"
							title="add to gift list" action="#{giftlistBean.addToGF()}"
							oncomplete="PF('added').show()">
							<f:setPropertyActionListener value="#{glDTO}"
								target="#{giftlistBean.gfSelezionata}" />
						</p:commandButton>
					</p:column>


				</p:dataTable>

			</h:panelGrid>

			<p:dialog id="added" header="Product added" widgetVar="added"
				resizable="false" width="500" showEffect="fade" hideEffect="fade">
				<p:outputLabel>Product successfully added to selected gift list</p:outputLabel>
			</p:dialog>

		</p:outputPanel>




	</h:form>
</h:body>
</html>